package roguelike;

import java.awt.Color;

import jade.ui.TermPanel;
import jade.ui.Terminal;
import jade.util.datatype.ColoredChar;

public class Game {
	
	private Terminal term;

	private boolean running;
	
	public Game() {
		term = TermPanel.getFramedTerminal("My first roguelike");
		running = true;
	}
	
	public static void main(String [] args) throws InterruptedException {
		Game game = new Game();
		game.render();
		game.start();
	}
	
	public void update(char key) {
		if(key == 'l') {
			playerx++;
		}
		if(key == 'k') {
			playery++;
		}
		if(key == 'j') {
			playerx--;
		}
		if(key == 'i') {
			playery--;
		}
	}
	
	public void start() {
		while(running) {
			try {
				char key = term.getKey();
				this.update(key);
				this.render();
			}
			catch (InterruptedException e) {
				e.printStackTrace();
			}
			
		}
	}
	
	
	public void render() {
		term.clearBuffer();
		term.bufferChar(playerx, playery, player);
		term.bufferString(0, 0, "My first roguelike :D");
		term.refreshScreen();
	}
	
	private ColoredChar player = ColoredChar.create('@', Color.cyan);
	private int playerx = 10;
	private int playery = 10;
	
}